package crp.services.api.graphql.models;

import crp.core.course.domain.models.CourseFacultyEntity;
import crp.core.course.domain.models.CourseFacultyRole;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("CourseFaculty")
@Builder
@Getter
@AllArgsConstructor
public class CourseFacultyPayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private final String facultyNo;
    @NotNull
    private final String name;
    @NotNull
    private final CourseFacultyRole role;

    public static CourseFacultyPayload of(CourseFacultyEntity entity) {
        return CourseFacultyPayload.builder()
                .id(entity.getId())
                .facultyNo(entity.getFaculty().getFacultyNo())
                .name(entity.getFaculty().getName())
                .role(entity.getRole())
                .build();
    }

}
